<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:str="http://exslt.org/strings"
    extension-element-prefixes="str"
    version="1.0">

    <xsl:template name="render_ep_menu">
        <xsl:param name="epc_menu" />
        <xsl:param name="user_name" />
        <xsl:param name="user_level" />

        <xsl:variable name="epc_help_doc">
            <xsl:if test="//component[@id=$query//component[@active=1]/target_sequence/target[position()=last()]/@comp_id]/@help">
                <xsl:value-of select="//component[@id=$query//component[@active=1]/target_sequence/target[position()=last()]/@comp_id]/@help"/>
            </xsl:if>
            <xsl:if test="not(//component[@id=$query//component[@active=1]/target_sequence/target[position()=last()]/@comp_id]/@help)">
                <xsl:value-of select="//component[position()=1]/@help"/>
            </xsl:if>
        </xsl:variable>

        <div id="ep_menu" class="column">
            <div id="ep_menu_title">
                <img style="float: left" src="{$html_href}/static/images/component_title_left.png" />
                <img style="float: right" src="{$html_href}/static/images/component_title_right.png" />
                <div style="background-image: url('{$html_href}/static/images/component_title_bg.png')"><nobr>Expression Profiler Menu</nobr></div>
            </div>
            <ol id="ep_menu_body">
                <xsl:for-each select="$epc_menu/epc_target/menugroup">
                    <li><!-- <a title="{@label}"> --><b><xsl:value-of select="@label"/></b><!-- </a> -->
                        <ol class="menu" id="{@id}">
                            <xsl:for-each select="component">
                                <li>
                                    <a target="{@target}">
                                        <xsl:attribute name="href">
                                            <xsl:if test="@title='Component Help'">
                                                <xsl:if test="$epc_help_doc">javascript:epc_help('/static/help/<xsl:value-of select="$epc_help_doc"/>')</xsl:if>
                                                <xsl:if test="not($epc_help_doc)">javascript:alert('Coming soon...')</xsl:if>
                                            </xsl:if>
                                            <xsl:if test="not(@title='Component Help')">
                                                <xsl:if test="@href"><xsl:value-of select="@href"/></xsl:if>
                                                <xsl:if test="not(@href)"><xsl:value-of select="$cgi_href"/>/ep_ui.pl?render_component_ids=<xsl:value-of select="@id"/></xsl:if>
                                            </xsl:if>
                                        </xsl:attribute>
                                        <xsl:value-of select="@title"/>
                                    </a>
                                </li>
                            </xsl:for-each>
                        </ol>
                    </li>
                </xsl:for-each>
            </ol>
            <div id="ep_menu_username">
                <div>
                    <img src="{$html_href}/static/images/user.png" />
                    <span id="ep_user_name"><xsl:value-of select="$user_name" /></span>
                </div>
            </div>
            <div id="ep_menu_status">
                <span id="ep_node_name"><xsl:value-of select="$node_name" /></span>&#160;|&#160;<span id="ep_session_timeout">120 minutes left</span><br />
                <a><xsl:attribute name="href">javascript:ep_log_out('<xsl:value-of select="$user_name" />')</xsl:attribute>Log out</a>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>